package org.example.fancystudy.Lock;

/**
 * @author chaigq
 * @version 1.0
 * @date 2022/11/9 23:13
 */
public class ReEntryLockDemo {

    public synchronized void function (){
        System.out.println(Thread.currentThread().getName()+"\t ----come in");
        function1();
        System.out.println(Thread.currentThread().getName()+"\t ----end");
    }
    public synchronized void function1 (){
        System.out.println(Thread.currentThread().getName()+"\t ----come in");
        function2();
    }
    public synchronized void function2 (){
        System.out.println(Thread.currentThread().getName()+"\t ----come in");
    }

    public static void main(String[] args) {
        ReEntryLockDemo reEntryLockDemo = new ReEntryLockDemo();
        new Thread(() -> {
            reEntryLockDemo.function();
        }, "t1").start();
    }
}
